using System;

namespace DeflateLib
{
    /// <summary>
    /// Contains some GZip (RFC1952) header data.
    /// </summary>
    [Serializable]
    public class GZipHeader
    {
        public const int DeflateCompressionMethod = 8;
        public const int DeflateMaxComressionExtraFlag = 2;
        public const int DeflateFastComressionExtraFlag = 5;

        public const int FatOS = 0;
        public const int AmigaOS = 1;
        public const int VmsOS = 2;
        public const int Unix = 3;
        public const int VmCmsOS = 4;
        public const int AtariTOS = 5;
        public const int HpfsOS = 6;
        public const int MacintoshOS = 7;
        public const int ZSystemOS = 8;
        public const int CpMOS = 9;
        public const int Tops20OS = 10;
        public const int NtfsOS = 11;
        public const int QDOS = 12;
        public const int AcornOS = 13;
        public const int UnknownOS = 255;

        private byte cm = DeflateCompressionMethod;
        private string ftext = null;
        private ushort? fhcrc16 = null;
        private GZipExtra[] fextra = null;
        private string fname = null;
        private string fcomment = null;
        private uint mtime = 0;
        private byte xfx = 0;
        private byte os = UnknownOS;

        public byte CompressMethod
        {
            get { return cm; }
            set { cm = value; }
        }

        public string Text
        {
            get { return ftext; }
            set { ftext = value; }
        }

        public ushort? Crc16
        {
            get { return fhcrc16; }
            set { fhcrc16 = value; }
        }

        public GZipExtra[] Extra
        {
            get { return fextra; }
            set { fextra = value; }
        }

        public string Name
        {
            get { return fname; }
            set { fname = value; }
        }

        public string Comment
        {
            get { return fcomment; }
            set { fcomment = value; }
        }

        public uint ModificationTime
        {
            get { return mtime; }
            set { mtime = value; }
        }


        public byte ExtraFlags
        {
            get { return xfx; }
            set { xfx = value; }
        }

        public byte OS
        {
            get { return os; }
            set { os = value; }
        }
    }


    /// <summary>
    /// Extra data for GZip header
    /// </summary>
    /// <see cref="GZipInfo"/>
    [Serializable]
    public struct GZipExtra
    {
        public byte SI1;
        public byte SI2;
        public byte[] Data;
    }
}
